class ScorePanel{
    score:HTMLElement
    level:HTMLElement
    num1 = 0  //分数初始值
    num2 = 1  //等级初始值
    maxLevel:number  // 设置最大的等级
    setScore:number //设置多少分升一级
    constructor(setScore = 10,maxLevel = 10){
        this.setScore = setScore
        this.maxLevel = maxLevel
        this.score = document.querySelectorAll('#score span')[0] as HTMLLinkElement
        this.level = document.querySelectorAll('#score span')[1] as HTMLLinkElement
    }

    // 增加分数
    addScore(){
        this.score.innerText = ++this.num1 +''
        if(this.num1 % this.setScore === 0)
        {
            this.addLevel()
        }
    }

    // 升级
    addLevel(){
        if(this.num2 < this.maxLevel)
        {
            this.level.innerText = ++this.num2 +''
        }
    }
}

export default ScorePanel
